package com.wms.web.controller.wcs;

import com.wms.common.core.controller.BaseController;
import com.wms.common.core.domain.AjaxResult;
import com.wms.common.core.page.TableDataInfo;
import com.wms.common.utils.poi.ExcelUtil;
import com.wms.system.domain.entity.sale.SaleCustomer;
import com.wms.system.domain.wcs.ProjectInventory;
import com.wms.system.service.wcs.IProjectInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "存货管理")
@RestController
@RequestMapping("/wcs/projectInventory")
public class ProjectInventoryController extends BaseController {
    @Autowired
    private IProjectInventoryService projectInventoryService;

    /**
     * 获取存货管理信息列表
     */
    @ApiOperation("获取存货管理信息列表")
    @GetMapping("/list")
    public TableDataInfo list(ProjectInventory projectInventory) {
        startPage();
        List<ProjectInventory> list = projectInventoryService.queryList(projectInventory);
        return getDataTable(list);
    }


    @ApiOperation("详情")
    @PostMapping("/detail")
    public AjaxResult detail(@RequestBody ProjectInventory projectInventory) {
        return AjaxResult.success(projectInventoryService.detail(projectInventory));
    }


    /**
     * 新增存货管理信息
     */
    @PostMapping(value = "/add")
    @ApiOperation("新增存货管理信息")
    public AjaxResult add(@RequestBody ProjectInventory projectInventory) {
        projectInventoryService.insert(projectInventory);
        return AjaxResult.success();
    }

    /**
     * 修改存货管理
     */
    @ApiOperation("修改存货管理信息")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ProjectInventory projectInventory) {
        projectInventoryService.update(projectInventory);
        return AjaxResult.success();
    }


    /**
     * 批量删除
     */
    @ApiOperation("批量删除存货管理信息")
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        projectInventoryService.delete(ids);
        return AjaxResult.success();
    }


//    /**
//     * 存货管理导入模板下载
//     */
//    @ApiOperation("存货管理导入模板下载")
//    @PostMapping("/importTemplate")
//    public void importTemplate(HttpServletResponse response) {
//        ExcelUtil<ProjectInventory> util = new ExcelUtil<>(ProjectInventory.class);
//        util.importTemplateExcel(response, "存货管理导入模板");
//    }
//
//
//    /**
//     * 存货管理导入
//     */
//    @ApiOperation("存货管理导入")
//    @PostMapping("/import")
//    public AjaxResult importProject(@RequestParam("file") MultipartFile file, boolean updateSupport) throws Exception {
//        ExcelUtil<ProjectInventory> util = new ExcelUtil<>(ProjectInventory.class);
//        List<ProjectInventory> list = util.importExcel(file.getInputStream());
//        String message = saleCustomerService.insertBatch(boardVoList, updateSupport);
//        return AjaxResult.success(message);
//    }

    /**
     * 存货管理信息导出
     */
    @ApiOperation("存货管理导出")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectInventory projectInventory) {
        List<ProjectInventory> list = projectInventoryService.queryList(projectInventory);
        ExcelUtil<ProjectInventory> util = new ExcelUtil<>(ProjectInventory.class);
        util.exportExcel(response, list, "存货管理");
    }

}
